<template>
  <el-container>
    <el-header>
      <h1 class="title">欢迎使用惊喜一餐！</h1>
    </el-header>
    <el-main>
      <el-row :gutter="20">
        <!-- 使用 v-for 渲染每个餐厅 -->
        <el-col :span="8" v-for="restaurant in recommendedRestaurants" :key="restaurant.id">
          <el-card :body-style="{ padding: '20px' }" class="restaurant-card">
            <div class="restaurant-image-container">
              <img :src="restaurant.image" class="restaurant-image" alt="餐厅图片" />
            </div>
            <div class="restaurant-info">
              <h3 class="restaurant-name">{{ restaurant.name }}</h3>
              <el-rate :value="restaurant.rating" disabled class="rating" />
              <p class="restaurant-description">{{ restaurant.description }}</p>
              <el-button type="primary" @click="viewDetails(restaurant.id)" class="detail-button">查看详情</el-button>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-main>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      recommendedRestaurants: [
        { id: 1, name: '中式餐厅', image: '/images/restaurantA.jpg', rating: 5.0, description: '美味的中餐，口味丰富。' },
        { id: 2, name: '意大利餐厅', image: '/images/restaurantB.jpg', rating: 5.0, description: '正宗的意大利餐，地道美味。' },
        { id: 3, name: '温馨餐厅', image: '/images/restaurantC.jpg', rating: 5.0, description: '舒适的环境与服务，适合聚会。' },
        { id: 4, name: '法式餐厅', image: '/images/restaurantD.jpg', rating: 5.0, description: '高端的法式餐厅，享受一流的美食体验。' },
        { id: 5, name: '日式餐厅', image: '/images/restaurantE.jpg', rating: 5.0, description: '新开的一家日式餐厅，环境优雅，味道鲜美。' },
        { id: 6, name: '火锅烧烤店', image: '/images/restaurantF.jpg', rating: 5.0, description: '主打烧烤和火锅，特别适合朋友聚餐。' }
      ]
    };
  },
  methods: {
    viewDetails(id) {
      // 跳转到餐厅详情页
      this.$router.push({ name: 'RestaurantInfo', params: { id } });
    }
  }
};
</script>

<style scoped>
.title {
  text-align: center;
  color: #409eff;
  font-size: 32px;
  margin-top: 20px;
}

.restaurant-card {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background-color: #ffffff;
}

.restaurant-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.restaurant-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 180px;
}

.restaurant-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.restaurant-info {
  padding: 10px 0;
  text-align: center;
}

.restaurant-name {
  font-size: 22px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.restaurant-description {
  color: #777;
  font-size: 14px;
  margin-bottom: 10px;
}

.el-rate {
  margin-bottom: 10px;
}

.rating .el-rate__icon {
  color: #fdd835;
}

.detail-button {
  margin-top: 10px;
  width: 100%;
  background-color: #409eff;
  color: white;
  border-color: #409eff;
}

.detail-button:hover {
  background-color: #66b1ff;
  border-color: #66b1ff;
}
</style>
